<?php
include '../conn.php';
include 'a-cookie.php';
$tid=$_GET['Id'];
$sql="select TeacherId,TeacherName,Sex,Tel,Depart,email,QQ from teacher WHERE  TeacherId=$tid";
$result=mysqli_query($conn,$sql);

?>

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人资料-教师端</title>
    <link rel="stylesheet" type="text/css" href="../css/htmleaf-demo.css">
    <link rel="stylesheet" type="text/css" href="../css/nav.css">
    <link rel="stylesheet" type="text/css" href="../fonts/iconfont.css">

    <link rel="stylesheet" href="../css/bootstrap-theme.css" />

    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css" />
    <link rel="stylesheet" href="../css/bootstrap.css" />
    <script type="text/javascript" src="../js/bootstrap3.0.3.min.js"></script>
    <link rel="stylesheet" type="text/css" href="../css/style.css">
        <style>
            button{
                background-color:darkgreen;
                font-family:"黑体";
                /*font-size: 23px;*/
                border: none;
                width:30%;
                text-align: center;
            }
        </style>
</head>
<body>

<div >
    <div class=" panel-default auto" align="center">


        <div class="panel-body">
            <div class="a">
                <img  id="avatarPreview" src="../img/教师头像.gif" class="touxiang" title="点击更换图片">
            </div>


            <table class="tab panel panel-default" id="table">
                <?
                while($row=mysqli_fetch_array($result))
                {
                    ?>
                    <tr class="c">
                        <td>工号:</td>
                        <td><input type="text" value="<?php echo $row['TeacherId']?>" id="input"  readonly="readonly" name="TecherId"/></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr class="c">
                        <td>姓名:</td>
                        <td><input type="text" value="<?php echo $row['TeacherName']?>" id="input1"  readonly="readonly" name="Teachername"/>	</td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr class="c">
                        <td>性别:</td>
                        <td><input type="text" value="<?php echo $row['Sex']?>"  id="input2"  readonly="readonly" name="Sex"/></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>

                    <tr class="c">
                        <td>手机:</td>
                        <td><input type="text" value="<?php echo $row['Tel']?>" id="input3"  readonly="readonly" name="Tel"/></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr class="c">
                        <td>E-mail:</td>
                        <td><input type="email" value="<?php echo $row['email']?>" id="input4"  readonly="readonly" name="email"/></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr class="c">
                        <td>QQ:</td>
                        <td><input type="text" value="<?php echo $row['QQ']?>" id="input5"  readonly="readonly" name="QQ"/></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                    <tr class="c">
                        <td>系别:</td>
                        <td><input type="text" value="<?php echo $row['Depart']?>" id="input6"  readonly="readonly" name="Depart"/></td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                    </tr>
                <?php
                }
                ?>
                <tr class="c">
                    <td></td>
                    <td>
                        <button id="edit" name="edited" onclick="change()"  style="color:white">修改</button>
                        <button id="save" name="saved"  value="t-manage" onclick="save(this)"  style="color:white">保存</button>
                    </td>
                </tr>
            </table>

        </div>
    </div>
    <script type="text/javascript"></script>
    <script>
        window.jQuery || document.write('<script src="../js/jquery-1.11.0.min.js"><\/script>')
    </script>
    <script type="text/javascript" src="../js/nav.js"></script>
    <script type="text/javascript">
        function change(){
            document.getElementById("input1").readOnly = false;
            document.getElementById("input1").style.border="1px solid #000000";
            document.getElementById("input2").readOnly = false;
            document.getElementById("input2").style.border="1px solid #000000";
            document.getElementById("input3").readOnly = false;
            document.getElementById("input3").style.border="1px solid #000000";
            document.getElementById("input4").readOnly = false;
            document.getElementById("input4").style.border="1px solid #000000";
            document.getElementById("input5").readOnly = false;
            document.getElementById("input5").style.border="1px solid #000000";
            document.getElementById("input6").readOnly = false;
            document.getElementById("input6").style.border="1px solid #000000";
        }

        function save(t) {
            var a=t;
//                alert(a);
            var b=a.parentNode.parentNode.parentNode.getElementsByTagName("input");

            var datas=new Array();
            for(var i = 0; i < b.length; i++) {
                datas[i]= encodeURI(b[i].value);
            }

            var msg = "您真的确定要修改吗？请确认！";
            if (confirm(msg)==true){
                $.ajax({
                    type: "GET",
                    url: "manage.php",
                    data: "&TeacherId="+datas[0]+"&TeacherName="+datas[1]+"&Sex="+datas[2]+"&Tel="+datas[3]+
                    "&email="+datas[4]+"&QQ="+datas[5]+"&Depart="+datas[6]+"&saved=t-change",
                    error:function(msg){
                        return false
                    },
                    success: function(msg){
                        alert( msg );
//                        myWindow=window.open("t-information.php","_self");
                    }
                });
            }

            for(var i = 0; i < b.length; i++) {
                b[i].readOnly = true;
                b[i].style.border = "0";
            }
        }
    </script>

</body>

</html>
